/**
 * 功能描述 卡片
 */

define(function (require, exports, module) {
	var Form = require("form");
	var enums = require("enums");
	var store =require("store");
	var activeUser = store.get("user");
	
    var instance = {
        initComponent: function (params,widget) {
        	var editform=new Form({
        		parentNode:".J-editform",
        		model:{
	  				layout:"3_1",
					id:"visitway",
					defaultButton:false,
					items:[{
						name:"pkCheckIn",
						type:"hidden"
					},{
						name:"version",
						type:"hidden",
						defaultValue:"0"
					},{
						name: "houseTypeName",
						label: "房型",
						readonly: true
					},{
						name: "roomPrice",
						label: "房价",
						readonly: true
					},{
						name: "checkInPrice",
						label: "入住价",
						validate : [ "required" ],
					},{
						name: "checkInPriceMark",
						label: "入住价说明"
					},{
						name: "checkInType",
						label: "入住类型",
						type: "select",
						options: enums["com.eling.elcms.travel.model.RoomRegister.CheckInType"]
					},{
						name:"waterElectric",
						label:"房价是否含水电费",
						type:"select",
						options: [{
	                         key : "true",
	                         value : "是"
	                     },{
	                         key : "false",
	                         value : "否"
	                    }],
	                    defaultValue:"false",
						validate:["required"],
						events:{
							"change":function(e){
								if(editform.getValue("waterElectric")=="true"){
									this.set("waterMeter",editform.getValue("waterMeter"));
									this.set("electricMeter",editform.getValue("electricMeter"));
									editform.setValue("waterMeter","");
									editform.setValue("electricMeter","");
								}else{
									
									var waterMeter = this.get("waterMeter");
									var electricMeter = this.get("electricMeter");
									editform.setValue("waterMeter",waterMeter);
									editform.setValue("electricMeter",electricMeter);
								}
							}
						}
					},{
						name:"waterMeter",
						type:"text",
						label:"水表抄表值（立方）",
					},{
						name:"electricMeter",
						label:"电表抄表值（度）",
						type:"text",
					},{
						name:"breakfast",
						label:"房价是否含早餐",
						type:"select",
						options: [{
	                         key : "true",
	                         value : "是"
	                     },{
	                         key : "false",
	                         value : "否"
	                    }],
	                    defaultValue:"false",
	                    validate:["required"],
					},{
						name:"date",
						id:"date",
						type:"date",
						label:"登记日期",
						mode:"YYYY.MM.DD",
						readonly:true,
						defaultValue:moment().format("YYYY.MM.DD")
					},{
						name:"operator",
						id:"operator",
						type:"text",
						label:"登记人",
						defaultValue:activeUser.name,
						readonly:true,
					},{
						name:"pkUser",
						type:"hidden",
					}]
				 }
	       	 });
       	 	widget.set("editform",editform);
        }
    };
    module.exports = instance;
});
